#!/usr/bin/env node
//进程间通信-父进程
const cp = require('child_process');

console.log('I am father process. PID:', process.pid);

let child = cp.fork('./11-ipc-child.js');

//事件响应
child.on('message', data => {
  console.log('I have message:', data);
});

setTimeout(() => {
  child.send('i am child');//给子进程发送消息
}, 2000);


setTimeout(() => {
  child.kill('SIGINT');
  process.exit();
}, 6000);

